package com.hotelsystem.dao;

import com.hotelsystem.pojo.RoomType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface RoomTypeMapper {

    /**
     * 按房型名称查询房型信息并按房间状态查询房间信息
     * @param typeName 类型名称
     * @param status 状态名称
     * @return
     * @throws Exception
     */
    List<RoomType> listByTypeNameAndStatus(@Param("typeName") String typeName, @Param("status") String[] status) throws Exception;

    /**
     * 修改房型的可用房间数、预订房间、入住房间、状态
     * @return
     * @throws Exception
     */
    @Update("update t_roomtype set usable = #{usable},reserved = #{reserved},check_in = #{checkIn},status = #{status} where room_type_id = #{roomTypeId}")
    Integer updateState(RoomType roomType) throws Exception;

    /**
     * 根据房型编号查询房型信息
     * @param roomTypeId 房型编号
     * @return
     * @throws Exception
     */
    @Select("select * from t_roomtype where room_type_id = #{roomTypeId}")
    RoomType get(Integer roomTypeId) throws Exception;

    //查询房间类型
    List<RoomType> getAllRoomType();

    /**
     * 通过对象查询出信息
     * @param roomType
     * @return
     */
    List<RoomType> getRoomTypesByRoomType(RoomType roomType);
    //从数据库中查询出所对应的

    /**
     * 查询出所对应的RoomType
     * @param roomTypeId
     * @return
     */
    RoomType getRoomTypeInfoById(Integer roomTypeId);

    /**
     * 根据Name查询RoomType
     * @param typeName
     * @return
     */
    RoomType getRoomTypeBytypeName(String typeName);
    //在删除房间和添加房间的时候 所对应的房间数量要改变

    /**
     * 修改RoomType
     * @param roomType
     * @return
     */
    Integer updateRoomTypeByRoomType(RoomType roomType);

    /**
     * 添加roomType
     * @param roomType
     * @return
     */
    Integer addRoomTypeByRoomType(RoomType roomType);

    /**
     * 删除类型Id
     * @return
     */
    Integer deleteRoomTypeBytypeId(Integer roomTypeId);

    /**
     * 通过类型查询出当前房屋可入住可预定的和 然后推出当前可用的房间数
     * @param roomTypeId
     * @return
     */
    Integer getAbleCheckInAndReserveSum(Integer roomTypeId);
}